﻿package mortal.game.scene3D.ai.ais
{
    import Message.Public.*;
    import com.gengine.global.*;
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.game.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.ai.base.*;
    import mortal.game.scene3D.map3D.sceneInfo.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.mvc.core.*;

    public class FlyBootAI extends AICommand
    {

        public function FlyBootAI()
        {
            return;
        }// end function

        override public function start(param1:Function = null) : void
        {
            super.start(param1);
            data.meRole.stopWalking(false);
            var _loc_2:* = data.params as SPassTo;
            if (Global.isDebugModle && (_loc_2.toPoint == null || _loc_2.toPoint.x < 0 || _loc_2.toPoint.y < 0))
            {
                Alert.show("呼叫基哥！, flyBootAI， toX=" + _loc_2.toPoint.x + ", toY=" + _loc_2.toPoint.y);
            }
            GameProxy.sceneProxy.covey(_loc_2);
            Dispatcher.addEventListener(EventName.ChangeScene, this.flyEnd);
            Dispatcher.addEventListener(EventName.ChangePosition, this.flyEnd);
            Dispatcher.dispatchEvent(new DataEvent(EventName.AI_FlyBootCalled));
            return;
        }// end function

        override public function stop(param1:Boolean = true) : void
        {
            Dispatcher.removeEventListener(EventName.ChangeScene, this.flyEnd);
            Dispatcher.removeEventListener(EventName.ChangePosition, this.flyEnd);
            super.stop(param1);
            return;
        }// end function

        protected function flyEnd(param1 = null) : void
        {
            this.stop();
            return;
        }// end function

        public static function checkCanFly(param1:int = -1, param2:Boolean = true) : Boolean
        {
            var _loc_3:SceneInfo = null;
            if (RolePlayer.instance.entityInfo.isInPVPFighting())
            {
                if (param2)
                {
                    MsgManager.showRollTipsMsg(Language.getString(20602));
                }
                return false;
            }
            if (Cache.instance.guild.isInGuild && !Cache.instance.guild.isInSelfGuild)
            {
                if (param2)
                {
                    MsgManager.showRollTipsMsg(Language.getString(20603));
                }
                return false;
            }
            if (!Game.sceneInfo.limitInfo.canPassTo())
            {
                if (param2)
                {
                    MsgManager.showRollTipsMsg(Language.getString(20604));
                }
                return false;
            }
            if (param1 > 0)
            {
                _loc_3 = SceneConfig.instance.getSceneInfo(param1);
                if (_loc_3 == null)
                {
                    return false;
                }
                if (!_loc_3.limitInfo.canPassTo())
                {
                    if (param2)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(20605));
                    }
                    return false;
                }
            }
            return true;
        }// end function

    }
}
